
class ComplexNumber {
    private double realPart;
    private double imaginaryPart;
    public ComplexNumber(double realPart, double imaginaryPart) {
        this.realPart = realPart;
        this.imaginaryPart = imaginaryPart;
    }
    public ComplexNumber add(ComplexNumber other) {
        return new ComplexNumber(this.realPart + other.realPart, this.imaginaryPart + other.imaginaryPart);
    }
    public ComplexNumber subtract(ComplexNumber other) {
        return new ComplexNumber(this.realPart - other.realPart, this.imaginaryPart - other.imaginaryPart);
    }
    @Override
    public String toString() {
        return realPart + " + " + imaginaryPart + "i";
    }
}
public class Week01 {
    public static void main(String[] args) {
        ComplexNumber c1 = new ComplexNumber(9, 5);
        ComplexNumber c2 = new ComplexNumber(3.1, 2.3);
        ComplexNumber sumResult = c1.add(c2);
        ComplexNumber diffResult = c1.subtract(c2);
        System.out.println("复数 c1 和 c2 的和为：" + sumResult);
        System.out.println("复数 c1 和 c2 的差为：" + diffResult);
    }
}